@extends('layout.master')

@section('title','商户详情')

@section('css')
    @parent
    <link href="{{ asset('css/calendar.css') }}" rel="stylesheet">
    <script src="{{ asset('js/calendar.js') }}" language="javascript"></script>
    <!-- animation CSS -->
    <link href="{{ asset('css/animate.css') }}" rel="stylesheet">
    <link href="{{ asset('plugins/bower_components/icheck/skins/all.css') }}" rel="stylesheet">
    <link href="{{ asset('plugins/bower_components/bootstrap-switch/bootstrap-switch.min.css') }}" rel="stylesheet">
    <style>
        .form-material .form-group.stySelect {
            overflow: visible;
        }

        .form-material button.form-control {
            padding: .8rem 25px .8rem 1.2rem;
            border: 1px solid #e4e7ea;
        }

        .dropify-wrapper {
            border: 0;
        }

        input {
            width: 300px;
            height: 30px;
            line-height: 30px;
            padding-left: 10px;
            box-sizing: border-box;
            display: block;
            margin-top: 5px;
        }

        .input_box {
            width: 300px;
            height: 30px;
            /*margin:100px auto;*/
            position: relative;
        }
    </style>
@endsection
@section('main')
    <div class="row">
        <div class="col-lg-12 col-md-12">
            <div class="white-box">
                <div class="row">
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">商户名称</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $shop->store_name }}" name="store_name"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">商户类型</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $shop->store_type }}" name="store_type"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <label class="col-md-12">商户地址</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $shop->address1 . $shop->address2 . $shop->address3 }}"
                                       name="address"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">营业时间</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $shop->business_time1 . ' ' . $shop->business_time2 }}"
                                       name="business_time"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">提现方式</label>
                            <div class="col-md-12">
                                <input type="text"
                                       value="{{ \App\ShopInfo::$WithdrawTypeDisplay[$shop->withdrawtype] }}"
                                       name="business_time"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="form-group">
                            <label class="col-md-12">简介</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $shop->introduce }}"
                                       name="introduce"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    @if(count($pics) > 0)
                        @foreach($pics as $value)
                            <div class="col-md-3 col-sm-3">
                                <label class="col-md-12">图片</label>
                                <div class="col-md-12">
                                    <div class="form-group ">
                                        <a class="btn default btn-outline image-popup-vertical-fit"
                                           href="{{ $value->pic }}"><img src="{{ $value->pic }}" width="100%"/></a>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    @endif
                </div>
                <div class="row">
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">组织机构代码</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $shop->organization_code }}" name="organization_code"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">法人姓名</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $shop->person_name }}" name="person_name"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">法人身份证号</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $shop->id_card }}" name="id_card"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-2">
                        <div class="form-group">
                            <label class="col-md-12">注册手机号</label>
                            <div class="col-md-12">
                                <input type="text" value="{{ $shop->login_phone }}" name="login_phone"
                                       class="form-control form-control-line" readonly>
                            </div>
                        </div>
                    </div>
                    @if($shop->status == \App\ShopInfo::STATUS_WAITING)
                        <div class="col-md-4">
                            <label class="col-md-12">信息审核</label>
                            <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="status-on">审核通过
                            </button>
                            <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="status-off">审核不通过
                            </button>
                        </div>
                    @endif
                </div>
                <div class="row">
                    <div class="col-md-3 col-sm-3">
                        <label class="col-md-12">头像</label>
                        <div class="col-md-12">
                            <div class="form-group ">
                                <a class="btn default btn-outline image-popup-vertical-fit"
                                   href="{{ $shop->head_portrait_url }}"><img src="{{ $shop->head_portrait_url }}"
                                                                              width="100%"/></a>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 col-sm-3">
                        <label class="col-md-12">身份证正面</label>
                        <div class="col-md-12">
                            <div class="form-group ">
                                <a class="btn default btn-outline image-popup-vertical-fit"
                                   href="{{ $shop->card_up }}"><img src="{{ $shop->card_up }}" width="100%"/></a>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 col-sm-3">
                        <label class="col-md-12">身份证背面</label>
                        <div class="col-md-12">
                            <div class="form-group ">
                                <a class="btn default btn-outline image-popup-vertical-fit"
                                   href="{{ $shop->card_down }}"><img src="{{ $shop->card_down }}" width="100%"/></a>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-3 col-sm-3">
                        <label class="col-md-12">组织机构证书</label>
                        <div class="col-md-12">
                            <div class="form-group ">
                                <a class="btn default btn-outline image-popup-vertical-fit"
                                   href="{{ $shop->organization }}"><img src="{{ $shop->organization }}" width="100%"/></a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12 col-md-12">
            <div class="white-box">
                <form class="form-horizontal form-material" id="editadmin" method="post" enctype="multipart/form-data">
                    <div class="row">
                        <div class="col-md-8 col-sm-8">
                            <div class="row">
                                <div class="col-md-2 col-sm-2">
                                    <label class="control-label">会员权限</label>
                                    <div class="example">
                                        <select style="height: 38px" name="type" id="vip">
                                            <option value="0"
                                                    @if($shop->consulttype === 0) selected @endif >无VIP
                                            </option>
                                            @foreach (App\Vip::select('id', 'title')->where('status', \App\Vip::STATUS_ON)->orderBy('weight')->get() as $value)
                                                <option value="{{ $value->id }}"
                                                        @if($shop->vip === $value->id) selected @endif >{{ $value->title }}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label class="col-md-12">当前会员到期时间</label>
                                        <div class="col-md-12">
                                            <input type="text" value="{{ date('Y-m-d H:i:s', $shop->vipendtime) }}"
                                                   class="form-control form-control-line">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-4 col-sm-4">
                                    <label class="control-label">选择充值后会员到期时间</label>
                                    <div class="input_box">
                                        <input type="text" placeholder="点击选择日期" id="choice_data1">
                                        <input type="hidden" id="vipendtime" name="vipendtime"
                                               value="{{ $shop->vipendtime }}">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-2 col-sm-6">
                                    <div class="form-group">
                                        <label class="col-md-12">纬度</label>
                                        <div class="col-md-12">
                                            <input type="text" name="lat" id="lat" value="{{ $shop->lat }}"
                                                   class="form-control form-control-line">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2 col-sm-6">
                                    <div class="form-group">
                                        <label class="col-md-12">经度</label>
                                        <div class="col-md-12">
                                            <input type="text" name="lng" id="lng" value="{{ $shop->lng }}"
                                                   class="form-control form-control-line">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2 col-sm-6">
                                    <div class="form-group">
                                        <label class="col-md-12">城市</label>
                                        <div class="col-md-12">
                                            <input type="text" name="city" id="city" value="{{ $shop->city }}"
                                                   class="form-control form-control-line">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-2 col-sm-6 form-group bt-switch">
                                    <div class="m-b-30">
                                        <label class="col-md-12">是否推荐</label>
                                        <div class="col-md-12">
                                            <input type="checkbox" data-on-color="success"
                                                   data-off-color="info"
                                                   @if(intval($shop->is_hot) === App\ShopInfo::HOT_ON) checked
                                                   @endif
                                                   name="is_hot"
                                                   id="hot"
                                                   data-on-text="是"
                                                   data-off-text="否">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-3 col-sm-6">
                                    <div class="form-group">
                                        <label class="col-md-12">店铺链接</label>
                                        <div class="col-md-12">
                                            <input type="text" name="url" id="url" value="{{ $shop->url }}"
                                                   class="form-control form-control-line">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-3 col-sm-6">
                                    <div class="form-group">
                                        <label class="col-md-12">店铺电话<span style="color: red; font-size: smaller">*多个手机号用一个空格隔开</span></label>
                                        <div class="col-md-12">
                                            <input type="text" name="phone" id="phone" value="{{ $phone }}"
                                                   class="form-control form-control-line">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-12 col-sm-12">
                                    <div class="form-group">
                                        <label class="col-md-12">主治</label>
                                        <div class="col-md-12">
                                            <input type="text" name="store_title" id="store-title" value="{{ $shop->store_title }}"
                                                   class="form-control form-control-line">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4 col-sm-4">
                            <div class="row">
                                <div class="col-md-12 col-sm-12">
                                    <label class="col-md-12">圈子权限</label>
                                    <select id='pre-selected-options' class="huati-id" multiple='multiple'>
                                        @foreach(DB::table('tbl_huati')->select('id', 'title')->get() as $item)
                                            <option value='{{ $item->id }}'
                                                    @if(in_array($item->id, $huati_id)) selected @endif>{{ $item->title }}</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="modify">更新信息
                        </button>
                        {!! csrf_field() !!}
                    </div>
                </form>
            </div>
        </div>
    </div>

    {{--是否有待审核的新信息--}}
    @if($shop->status == \App\ShopInfo::STATUS_NEW)
        <div class="row">
            <div class="col-lg-12 col-md-12">
                <div class="white-box">
                    <form class="form-horizontal form-material" id="editadmin" method="post"
                          enctype="multipart/form-data">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="col-md-12">营业时间</label>
                                    <div class="col-md-12">
                                        <input type="text"
                                               value="{{ $shopinfo->business_time1 . ' ' . $shopinfo->business_time2 }}"
                                               name="business_time"
                                               class="form-control form-control-line" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="col-md-12">提现方式</label>
                                    <div class="col-md-12">
                                        <input type="text"
                                               value="{{ \App\ShopInfo::$WithdrawTypeDisplay[$shopinfo->withdrawtype] }}"
                                               name="business_time"
                                               class="form-control form-control-line" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="col-md-12">手机号</label>
                                    <div class="col-md-12">
                                        <input type="text" value="{{ $shopinfo->phone }}" name="phone"
                                               class="form-control form-control-line" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="col-md-12">简介</label>
                                    <div class="col-md-12">
                                        <input type="text" value="{{ $shopinfo->introduce }}"
                                               name="introduce"
                                               class="form-control form-control-line" readonly>
                                    </div>
                                </div>
                            </div>
                            @foreach(json_decode($shopinfo->piclist) as $value)
                                <div class="col-md-3 col-sm-3">
                                    <label class="col-md-12">图片</label>
                                    <div class="col-md-12">
                                        <div class="form-group ">
                                            <a class="btn default btn-outline image-popup-vertical-fit"
                                               href="{{ $value }}"><img src="{{ $value }}" width="100%"/></a>
                                        </div>
                                    </div>
                                </div>
                            @endforeach
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="new-on">审核通过
                                </button>
                                <button class="fcbtn btn btn-success btn-outline btn-1e waves-effect" id="new-off">审核不通过
                                </button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    @endif
@endsection
@section('js')
    @parent
    <script src="{{ asset('js/myself.js') }}"></script>
    <!-- icheck -->
    <script src="{{ asset('plugins/bower_components/icheck/icheck.min.js') }}"></script>
    <script src="{{ asset('plugins/bower_components/icheck/icheck.init.js') }}"></script>
    <script src="{{ asset('js/jasny-bootstrap.js') }}"></script>
    <script src="{{ asset('plugins/bower_components/dropify/dist/js/dropify.min.js') }}"></script>
    <script src="{{ asset('plugins/bower_components/bootstrap-select/bootstrap-select.min.js') }}"
            type="text/javascript"></script>
    <!-- bt-switch -->
    <script src="{{ asset('plugins/bower_components/bootstrap-switch/bootstrap-switch.min.js') }}"></script>
    <script type="text/javascript">
        $(".bt-switch input[type='checkbox'], .bt-switch input[type='radio']").bootstrapSwitch();
        var radioswitch = function () {
            var bt = function () {
                var redio = $(".radio-switch");
                redio.on("switch-change", function () {
                    $(".radio-switch").bootstrapSwitch("toggleRadioState")
                });
                    redio.on("switch-change", function () {
                        $(".radio-switch").bootstrapSwitch("toggleRadioStateAllowUncheck")
                    });
                    redio.on("switch-change", function () {
                        $(".radio-switch").bootstrapSwitch("toggleRadioStateAllowUncheck", !1)
                    })
            };
            return {
                init: function () {
                    bt()
                }
            }
        }();
        $(document).ready(function () {
            radioswitch.init()
        });
        $(document).ready(function () {

            var calendar1 = new Calendar({
                "inputId": "#choice_data1",//绑定的input框id
                "startTime": "2009-6-4",//初始时间，时间格式不可变，月是1-12个月
                "endTime": "2040-10-2",//截止时间，时间格式不可变，月是1-12个月
                "dataFormat": "yy/MM/dd hh:mm:ss",//传入时间格式，不传则默认"yyyy-MM-dd hh:mm:ss"
                "isHourMin": true,//false表示只选年月日，不选小时分钟;不传或者true默认选择年月日小时分钟
                "isHourOnly": false,//true表示只选小时，不选分钟;不传或者false默认选择小时、分钟
                "showPosition": false,//是否根据input框定位，true是根据，false或不传是全屏居中
                "headColor": "#f36444",//主色调，默认为#f36444橘色
                "callback": function (_time) {
                    var __time = _time / 1000;
                    $("#vipendtime").val(__time);
                },//获得选择时间回调函数
                "showCallback": function () {
                    // console.log("show");
                },//弹出时的回调
                "hideCallback": function () {
                    // console.log("hide");
                },//弹出时的回调

            });
            calendar1.setConfig();
        });


        $('#pre-selected-options').multiSelect();

        $('#modify').click(function (e) {
            e.preventDefault();
            var phone = $("#phone").val();
            var lat = $("#lat").val();
            var lng = $("#lng").val();
            var hot = $("input[id='hot']:checked").length;
            var city = $("#city").val();
            var url = $("#url").val();
            var store_title = $("#store-title").val();
            var vip = $("#vip").val();
            var vipendtime = $("#vipendtime").val();
            var huati_id = $(".huati-id").val();

            var id = geturlid();

            swal({
                    title: "",
                    text: "确定修改么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/shop/vipModify/' + id,
                        // data: $('#editadmin').serialize(),// 你的formid
                        data: {
                            phone: phone,
                            lat: lat,
                            lng: lng,
                            hot: hot,
                            city: city,
                            url: url,
                            store_title: store_title,
                            vip: vip,
                            vipendtime: vipendtime,
                            huati_id: huati_id
                        },
                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });

        $('#status-on').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/shop/statusOn/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });
        $('#status-off').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定不通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/shop/statusOff/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });


        $('#new-on').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/shop/newStatusOn/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });
        $('#new-off').click(function (e) {
            e.preventDefault();
            var id = geturlid();

            swal({
                    title: "",
                    text: "确定不通过么？",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    confirmButtonText: "是的",
                    closeOnConfirm: false
                },
                function () {
                    $.ajax({

                        type: "POST",
                        url: '/shop/newStatusOff/' + id,

                        async: false,
                        headers: {
                            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                        },
                        error: function (err) {
                            Object.keys(err.responseJSON.errors).forEach(function (key) {
                                swal(key, err.responseJSON.errors[key][0]);
                                return false;
                            });
                        },
                        success: function (data) {
                            if (data.status === 1) {
                                swal(data.message, '', 'success');
                                $('.confirm').click(function () {
                                    location.reload();
                                });
                            } else {
                                swal(data.message);
                            }
                        }
                    });
                })
        });
    </script>
@endsection